﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnityFacade : MonoBehaviour
{
    private AudioManager _audioManager;

    private UIManager _uiManager;

    private ClientManager _clientManager;

    private RequestManager _requestManager;

    private ApplicationManager _applicationManager;
    
    public UIManager UiManager
    {
        get { return _uiManager; }
    }

    public AudioManager AudioManager
    {
        get { return _audioManager; }
    }

    public ClientManager ClientManager
    {
        get { return _clientManager; }
    }

    public RequestManager RequestManager
    {
        get { return _requestManager; }
    }

    private static UnityFacade _instance;

    public static UnityFacade Instance
    {
        get { return _instance; }
    }

    public ApplicationManager ApplicationManager
    {
        get { return _applicationManager; }
    }

    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }
    }

    // Use this for initialization
    void Start()
    {
        //实例化所有Manager
        _audioManager = new AudioManager();
        _uiManager = new UIManager();
        _clientManager = new ClientManager();
        _requestManager = new RequestManager();
        _applicationManager = new ApplicationManager();
        //调用所有的Manager的OnInit方法
        _audioManager.OnInit();
        _uiManager.OnInit();
        _clientManager.OnInit();
        _requestManager.OnInit();
        _applicationManager.OnInit();
        
    }

    // Update is called once per frame
    void Update()
    {
        _audioManager.OnUpdate();
        _uiManager.OnUpdate();
        _clientManager.OnUpdate();
        _requestManager.OnUpdate();
        _applicationManager.OnUpdate();
    }

    private void OnDestroy()
    {
        _audioManager.OnDestroy();
        _uiManager.OnDestroy();
        _clientManager.OnDestroy();
        _requestManager.OnDestroy();
        _applicationManager.OnDestroy();
        

    }

    


   
}